/*
package com.cyy.cn;

import com.mongodb.BasicDBObject;
import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.BasicBSONObject;
import org.bson.Document;

import java.util.HashMap;
import java.util.Map;

*/
/**
 * mongoDb测试类
 *//*

public class MongoDBTest {

   */
/* public static void main(String[] args) {
        MongoClient mongoClient = new MongoClient("203.195.206.164");
        MongoDatabase database = mongoClient.getDatabase("spit");
        MongoCollection<Document> spit = database.getCollection("spit");
        BasicDBObject json = new BasicDBObject("userid","1012");
        //FindIterable<Document> documents = spit.find();//查询文档集合
        FindIterable<Document> documents = spit.find(json);//查询文档集合
        for (Document document : documents) {
            System.out.println("序号:" + document.get("_id"));
            System.out.println("内容:" + document.get("content"));
            System.out.println("用户id:" + document.get("userid"));
            System.out.println("昵称:" + document.get("nickName"));
            System.out.println("排序号:" + document.get("orderNo"));
        }
        mongoClient.close();
    }  *//*


 */
/*   public static void main(String[] args) {
        MongoClient mongoClient = new MongoClient("203.195.206.164");
        MongoDatabase database = mongoClient.getDatabase("spit");
        MongoCollection<Document> spit = database.getCollection("spit");
        BasicDBObject json = new BasicDBObject("orderNo",new BasicDBObject("$gt",111));
        //FindIterable<Document> documents = spit.find();//查询文档集合
        FindIterable<Document> documents = spit.find(json);//查询文档集合
        for (Document document : documents) {
            System.out.println("序号:" + document.get("_id"));
            System.out.println("内容:" + document.get("content"));
            System.out.println("用户id:" + document.get("userid"));
            System.out.println("昵称:" + document.get("nickName"));
            System.out.println("排序号:" + document.get("orderNo"));
        }
        mongoClient.close();
    }*//*


    public static void main(String[] args) {
        MongoClient mongoClient = new MongoClient("203.195.206.164");
        MongoDatabase database = mongoClient.getDatabase("spit");
        MongoCollection<Document> spit = database.getCollection("spit");

        Map<String,Object> map = new HashMap<>();
        map.put("content","测试插入mongoDB");
        map.put("userid","19950826");
        map.put("nickName","永别了牢笼");
        map.put("orderNo","4000");
        Document document = new Document(map);
        spit.insertOne(document);
        mongoClient.close();
    }
}
*/
